package pe.edu.upc.dsd.clienteweb.controller;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.ui.ModelMap;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.support.SessionStatus;

import pe.edu.upc.dsd.clienteweb.model.Embarque;

@Controller
@RequestMapping("/consultaEmbarque")
public class EmbarqueController {
private Logger logger = Logger.getLogger(EmbarqueController.class);
	
	//@Autowired
	//private ClienteService clienteService;  // Asociar el webservice
	
	@RequestMapping(method = RequestMethod.GET)
	public String initForm(ModelMap model){
 
		logger.debug("Ingresando al formulario consulta embarque " );
	
		// Embarque embarque = new Embarque();
		
		//command object
		//model.addAttribute("embarque", embarque);
 
		//return form view
		return "consultaembarque";
	}
	
	@RequestMapping(method = RequestMethod.POST)
	public String processSubmit(
		@ModelAttribute("embarque") Embarque embarque,
		BindingResult result, SessionStatus status,Model model) {
 
		//clear the command object from the session
		status.setComplete(); 
		
		//logger.debug("Ingresando a registrar cliente " + cliente.getNombre());
		
		//Respuesta respuesta = clienteService.registrarCliente(cliente);
		
		//logger.debug(respuesta.getMensaje());
		
		//model.addAttribute("mensaje",respuesta.getMensaje());
 
		//return form success view
		return "consultaembarque";
	}
}
